home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8676 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: gambier.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help referencing an array of strings
  5. Date: 5 Mar 1996 13:01:38 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4hia3iINN4dn@gambier.ugrad.cs.ubc.ca>
  8. References: <313C7F02.5D54@interramp.com>
  9. NNTP-Posting-Host: gambier.ugrad.cs.ubc.ca
  10.  
  11. In article <313C7F02.5D54@interramp.com>,
  12. James A. Clifton <jclifton@interramp.com> wrote:
  13.  >I need to have an array of fixed-length strings in a structure.
  14.  >The problem I am having is trying to reference a particular string
  15.  >in the array:
  16.  >
  17.  >typedef struct ss {
  18.  >/* some other data */
  19.  >char sa[N][M];
  20.  >} ss;
  21.  >
  22.  >ss s;
  23.  >
  24.  >Now how do I reference the Nth string??? 
  25.  >
  26.  >I know how to reference the Mth character in the Nth string:
  27.  >
  28.  >s.sa[n][m]
  29.  >
  30.  >But not the Nth entire string, I've tryed:
  31.  >
  32.  >s.sa[n][] and *s.sa[n] but neither works.
  33.  
  34. Too bad you did not try a mere s.sa[n]. This is an array of M characters, which
  35. decays into a pointer; i.e. string. The locution &s.sa[n][0] will also work
  36. (address of the first character of string n).
  37.  
  38. Are you making sure that the strings are zero-terminated, by the way?
  39. -- 
  40.  
  41.